package testApplets;

import javax.vecmath.Point3f;

import com.sun.j3d.utils.geometry.GeometryInfo;

import processing.core.PApplet;

public class TestTtriangulate extends PApplet{
public void setup(){
	size(1024,768);
	
	 float[] m_VertexArray = { 1, 1, 0, //0
		      0, 3, 0, //1
		      1, 5, 0, //2
		      2, 4, 0, //3
		      4, 5, 0, //4
		      3, 3, 0, //5
		      4, 2, 0, //6
		      4, 0, 0, //7
		      3, 0, 0, //8
		      2, 1, 0, //9
		      // these are vertices for the hole
		      1, 3, 0, //10
		      2, 2.7f, 0, //11
		      3, 2, 0, //12
		      3.2f, 1, 0, //13
		      2, 2, 0 };//14
	 GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
	 gi.setCoordinates(m_VertexArray);
	 int[] stripCountArray = { 10, 5 };
	 int[] countourCountArray = { stripCountArray.length };

	 gi.setContourCounts(countourCountArray);
	 gi.setStripCounts(stripCountArray);
	 
	 gi.convertToIndexedTriangles();
	 indexes=gi.getCoordinateIndices();
	 pts=gi.getCoordinates();
	 println(pts);
}
int[] indexes;
Point3f[] pts;
public void draw(){
	stroke(255,0,0);
	fill(255);
	scale(100);
	strokeWeight(0.01f);
	beginShape(TRIANGLES);
	for (int i=0;i<indexes.length;i++){
		Point3f cPt=pts[indexes[i]];
		
		vertex(cPt.x,cPt.y);
	}
	endShape();
}
}
